﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace TextLineUpdate
{
    /// <summary>
    /// 文字列をコピーするための画面
    /// </summary>
    public partial class CopyString : Form
    {
        #region 変数
        private string _copyAlString;
        #endregion

        #region プロパティ
        public string CopyAllString
        {
            get
            {
                return this._copyAlString;
            }
            set
            {
                this._copyAlString = value;
            }
        }

        public int TextMaxLength
        {
            get
            {
                return this.textBoxAllText.MaxLength;
            }
        }
        
        #endregion

        #region メソッド
        //コンストラクタ
        public CopyString()
        {
            InitializeComponent();
            //中央表示
            StartPosition = FormStartPosition.CenterScreen;
        }
        #endregion

        #region イベント
        /// <summary>
        /// フォーム_Load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CopyString_Load(object sender, EventArgs e)
        {
            this.textBoxAllText.Text = this._copyAlString;
        }

        /// <summary>
        /// 閉じる
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        

        /// <summary>
        /// フォーム_KeyDown
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CopyString_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode != Keys.Shift && e.KeyCode != Keys.Alt)
            {
                if (e.KeyCode == Keys.Enter)
                {
                    if (this.ActiveControl == this.textBoxAllText)
                    {
                        return;
                    }

                    this.SelectNextControl(this.ActiveControl, true, true, false, false);
                    e.Handled = true;
                }
            }
            //全選択のショートカットキーが押された場合
            if (e.Control && e.KeyCode == Keys.A)
            {
                //AllTextにフォーカスがある場合
                if (this.ActiveControl == this.textBoxAllText)
                {
                    //全選択する
                    this.textBoxAllText.SelectAll();
                }
            }
        }

        #endregion
    }
}